cat >>my1.cnf <<EOF
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
server-id=1
binlog-format=ROW
log-bin=mysql-bin
binlog-do-db=heima
EOF

cat >>my2.cnf <<EOF
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
server-id=2
binlog-format=ROW
log-bin=mysql-bin
binlog-do-db=heima
EOF


//主
docker exec -it mysql1 bash
mysql -uroot -p1450554809@Aa
CREATE USER 'canal' @'%' IDENTIFIED BY 'canal';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal' @'%';
flush privileges;
ALTER USER 'canal'@'%' IDENTIFIED WITH mysql_native_password BY 'canal';
show MASTER status;
binlog.000003  1168



//从
docker exec -it mysql2 bash
mysql -uroot -p1450554809@Aa
change master to master_host='192.168.4.2', master_user='canal' ,master_password='canal', master_port=3306,master_log_file='mysql-bin.000003', master_log_pos=1168,master_connect_retry=30;
start slave;
show slave status\G;


